class BrowseController < ApplicationController

  def auto_complete_for_browse_item
    value = params[:browse][:item]
    @items = Item.find(:all, :select => "name", :conditions => ['published = 1 AND marketgroup_id IS NOT NULL AND LOWER(name) LIKE ?',  
          "%#{value.downcase}%"], :order => 'name ASC', :limit => 10)
    render :partial => 'items'
  end  
  
  def search
    @query = params[:q] || ""
    @items = Item.search(@query)
    if @items.empty?
      flash[:notice] = "Sorry nothing found!"
      redirect_to :action => "index"
    else
      render_partial_collection "item", @items
    end
  end
  
	def market
		@query = params[:q] || ""
    @items = Item.search(@query)
    if @items.empty?
      flash[:notice] = "Sorry nothing found!"
      redirect_to :action => "index"
    else
      render_partial_collection "market_item", @items
    end
	end

	def show_market
    unless params[:id]
      redirect_to :action => "index"
    end
    @prices = Item.find(params[:id]).prices 
	end
  
  def show
    unless params[:id]
      redirect_to :action => "index"
    end
    @item = Item.find(params[:id]) 
  end
  
end
